Repository navigation
Rust: Model early Err returns in ? expressions - #23141
Merged
Merged
Conversation
hvitved
force-pushed
the
rust/try-expr-err-early-return
branch
from
November 16, 2026 13:47
b2a6ce3 to
7ee431f
Compare
hvitved
marked this pull request as ready for review
November 16, 2026 19:03
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new TryExpr early-return data-flow edge changes production analysis semantics without documented DCA results assessing changed alerts and unexpected regressions on real-world databases.
1 open issue
What changed in this PR
This PR addresses the missing Rust data-flow path described in #23065 by modeling values returned early through ?, with regression coverage for Result::Err.
Changes:
- Adds a synthetic early-return node and connects it to the operand of
?. - Tracks
Errpayloads through early returns while hiding synthetic nodes in flow paths. - Adds a global-flow regression case and updates expected test outputs.
| File | Description |
|---|---|
rust/ql/test/library-tests/dataflow/local/DataFlowStep.expected |
Records new local early-return edges. |
rust/ql/test/library-tests/dataflow/global/viableCallable.expected |
Updates callable expectations for the regression case. |
rust/ql/test/library-tests/dataflow/global/main.rs |
Tests error-payload flow through ? to unwrap_err(). |
rust/ql/test/library-tests/dataflow/global/inline-flow.expected |
Records expected global error-flow paths. |
rust/ql/lib/codeql/rust/dataflow/internal/Node.qll |
Defines the synthetic early-return node. |
rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll |
Adds early-return flow and error-content handling. |
Review effort: Balanced (adaptive)
paldepind
approved these changes
Nov 17, 2026
paldepind
left a comment
Contributor
There was a problem hiding this comment.
Looks good. Great to handle this :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #23065.